//
// Created by hunan on 25-7-13.
//

#include "download_net_operate.h"
#include "public_module/protocol_connection/http_protocol_operation.h"
#include "public_module/protocol_connection/protocol_connection_pool.h"

DownloadNetOperate::DownloadNetOperate(Loop * loop)
{
    m_loop = loop;
    m_net_operate = new ProtocolConnectionPool(loop);
}

DownloadNetOperate::~DownloadNetOperate()
{
    CloseConnection();
}

int DownloadNetOperate::ResizeConnection(int size) const
{
    HttpProtocolOperationFactory factory;
    return m_net_operate->InitProtocolConnectionPool(size, &factory);
}

std::shared_ptr<ProtocolConnection> DownloadNetOperate::GetConnection() const
{
    return m_net_operate->GetConnection();
}

void DownloadNetOperate::ReleaseConnection(const std::shared_ptr<ProtocolConnection>& connection) const
{
    m_net_operate->ReleaseConnection(connection);
}

void DownloadNetOperate::CloseConnection() const
{
    m_net_operate->CloseConnection();
}



